#pragma once
#pragma warning(disable : 26812)

#include "../QDraw.h"

QNamespaceStart(Qui)

enum QImageCutReact
{
	ImageCutEllipse, ImageCutRectangle
};

class QImage
{
	private:
		IMAGE save_image;

	public:
		QImage()
		{
			save_image = IMAGE(0, 0);

			QRenderimageAlpha(&save_image);
		}
		QImage(qsize_t width, qsize_t height)
		{
			save_image = IMAGE(width, height);

			QRenderimageAlpha(&save_image);
		}

	public:
		void cut_image(QImageCutReact cut_react, int width, int height);
		void cut_image_with_shadow(QImageCutReact cut_react, int width, int height, int offset_pixel);

	public:
		void load_from_file(LPCTSTR image_path, int width = 0, int height = 0,
					bool resize = false)
		{
			QLoadImage(&save_image, image_path, width, height, resize);
		}
		void load_from_source(IMAGE* image, LPCTSTR resouce_type, LPCTSTR source_name, int width = 0, int height = 0,
					bool resize = false)
		{
			QLoadImage(&save_image, resouce_type, source_name, width,
				height, resize);
		}

		void load_from_image(IMAGE image) { save_image = image; }

		qsize_t get_width() { return save_image.getwidth(); }
		qsize_t get_height() { return save_image.getheight(); }

		qsize_t get_size() { return get_width() * get_height(); }

		void    resize(qsize_t width, qsize_t height);

		IMAGE   get_image() { return save_image; }

		HDC     get_hdc()  { return QGetImageHDC(&save_image); }

		inline const 
			DWORD* get_buffer() { return GetImageBuffer(&save_image); }

		bool empty()
		{
			return save_image.getheight() == save_image.getheight() &&
				   save_image.getheight() == 0;
		}

		bool   operator==(QImage object)
		{
			return get_size() == object.get_size();
		}
		QImage operator=(QImage object)
		{
			save_image = object.save_image;
			
			return object;
		}
};

void QPutimage(int x, int y, QImage* image_beput, 
			int transparency, IMAGE* target);

QNamespaceEnd